function delete_init(what, displayText, delete_url, return_url) {

  var deleteCallback = {
    success: function(o) {
      myBusyPanel.hide();
      try {
        var response = YAHOO.lang.JSON.parse(o.responseText);
      } catch (e) {
        this.failure(o);
        return;
      }

      if (response.result == "success") {
        myDeleteComplete.show();
      } else {
        this.failure(o);
      }
    },
    failure: function(o) {
      myBusyPanel.hide();
      myFailureDialog.show();
    },
    cache:false
  }

  myFailureDialog = new YAHOO.widget.SimpleDialog('failureDialog', {
    width: "300px",
    effect: {effect:YAHOO.widget.ContainerEffect.FADE,
             duration:0.2},
    fixedcenter: true,
    modal: true,
    visible: false,
    draggable: true,
    icon: YAHOO.widget.SimpleDialog.ICON_ALARM,
    buttons: [ { text: "Dismiss",
                 handler: function() { this.hide(); } }
             ]
  });

  myFailureDialog.setHeader("Failed to delete "+what+".");
  myFailureDialog.setBody("Failed to delete "+what+".");
  myFailureDialog.render("hcp-doc");

  var handleYes = function() {
    this.hide();
    myBusyPanel.show();
    // XXX: Escaping URL?
    var transaction = YAHOO.util.Connect.asyncRequest('GET', delete_url,
                                                      deleteCallback, null);
  };
  var handleNo = function() {
    this.hide();
  };

  myDeleteConfirmation = new YAHOO.widget.SimpleDialog('deleteConfirmation', {
    width: "300px",
    effect: {effect:YAHOO.widget.ContainerEffect.FADE,
             duration:0.2},
    fixedcenter: true,
    modal: true,
    visible: false,
    draggable: true,
    icon: YAHOO.widget.SimpleDialog.ICON_WARN,
    buttons: [ { text: "Yes",
                 handler: handleYes },
               { text: "Cancel",
                 handler: handleNo,
                 isDefault: true } ]});

  myDeleteConfirmation.setHeader("Confirm delete "+what+".");
  myDeleteConfirmation.setBody("Are you sure you want to delete "+displayText+"?");
  myDeleteConfirmation.render("hcp-doc");


  var handleReturn = function() {
    window.location = return_url;
  };

  myDeleteComplete = new YAHOO.widget.SimpleDialog('deleteComplete', {
    width: "300px",
    effect: {effect:YAHOO.widget.ContainerEffect.FADE,
             duration:0.2},
    fixedcenter: true,
    modal: true,
    close: false,
    visible: false,
    draggable: true,
    icon: YAHOO.widget.SimpleDialog.ICON_INFO,
    buttons: [ { text: "OK",
                 handler: handleReturn }
             ]});

  myDeleteComplete.setHeader("Delete Complete");
  myDeleteComplete.setBody("Deleted "+what+".");
  myDeleteComplete.render("hcp-doc");

  myBusyPanel = new YAHOO.widget.Panel("busy", {
    width: "240px",
    fixedcenter: true,
    close: false,
    draggable: false,
    modal: true,
    visible: false,
    timeout: 10000,
  });

  myBusyPanel.setHeader("Processing, please wait...");
  myBusyPanel.setBody('<img src="/images/busy.gif" />');
  myBusyPanel.render("hcp-doc");

  YAHOO.util.Event.addListener("hcp-delete-button", "click",
                               myDeleteConfirmation.show,
                               myDeleteConfirmation,
                               true);
}
